<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://unpkg.com/vue"></script>
    <script>
        window.onload = function() {
            /*new Vue({
             el: '#app',
             data: {
             message: '@.@ Hello Vue.js!'
             //输出
             }
             })
             var app2 = new Vue({
             el: '#app-2',
             data: {
             message: '页面加载于 ' + new Date().toLocaleString()
             }
             })
             var app3 = new Vue({
             el: '#app-3',
             data: {
             seen: true
             }
             })*/
            var app4;
            app4 = new Vue({
                el: '#app-4',
                data: {
                    userName: '',
                    Age: null,
                    message: 'hello Vue.js!',
                    peoples: [
                        {Name: "a", Age: "11"},
                        {Name: "b", Age: "12"}
                    ]
                },
                methods: {
                    reversMessage: function () {
                        this.message = this.message.split('').reverse().join('')
                        //逆转
                    },
                    addpeople: function () {
                        var x = {Name: this.userName, Age: this.Age};
                        this.peoples.push(x);
                    },
                    removeall: function () {
                        this.peoples = [];
                    },
                    remove: function (index) {
                        this.peoples.splice(index, 1);
                    },


                },
                filters: {
                    /*formatDate(time) {
                        var date = new Date(time);
                        return formatDate(date, yyyy-MM-dd-hh-mm);
                    }*/
                }
            });
        }
    </script>
</head>
<body>
<!--<div id="app">
<p>{{ message }}</p>
</div>
<div id="app-2">
<span v-bind:title="message">
鼠标悬停几秒钟查看此处动态绑定的提示信息！
 </span>
</div>
<div id="app-3">
<p v-if="seen">现在你看到我了</p>
</div>-->
<div id="app-4">
    <p>{{ message }}</p>
    姓名：<input v-model = "userName"><br>
    年龄：<input v-model = "Age"><br><br>
    <button v-on:click="addpeople">增加 </button>
    <button v-on:click="removeall">全部删除</button><br><br>
    <table border="1">
        <tr><th>序号</th><th>姓名</th><th>年龄</th><th>时间</th><th>操作</th></tr>
        <tr v-for="(people,index) in peoples">
            <td>{{index+1}}</td>
            <td>{{ people.Name }}</td>
            <td>{{ people.Age }}</td>
            <td ></td>
            <td><button v-on:click="remove(index)">删除</button></td>
        </tr>
    </table>
</div>


</body>
</html>